



export default class CustomMaterial extends Laya.Material {

    static DIFFUSETEXTURE = Laya.Shader3D.propertyNameToID("u_texture");
    static MARGINALCOLOR = Laya.Shader3D.propertyNameToID("u_marginalColor");

    static BLEND: number = Laya.Shader3D.propertyNameToID("s_Blend");
    static CULL: number = Laya.Shader3D.propertyNameToID("s_Cull");
    static BLEND_SRC: number = Laya.Shader3D.propertyNameToID("s_BlendSrc");
    static BLEND_DST: number = Laya.Shader3D.propertyNameToID("s_BlendDst");
    static DEPTH_TEST: number = Laya.Shader3D.propertyNameToID("s_DepthTest");
    static DEPTH_WRITE: number = Laya.Shader3D.propertyNameToID("s_DepthWrite");

    constructor() {
        super();

        //super(3);
        // this._addReference(3);//Reference
        this.setShaderName("CustomShader");

        this.renderQueue = Laya.Material.RENDERQUEUE_TRANSPARENT;
        this.alphaTest = false;
        this._shaderValues.setBool(CustomMaterial.DEPTH_WRITE, false);
        this._shaderValues.setInt(CustomMaterial.CULL, Laya.RenderState.CULL_BACK);
        this._shaderValues.setInt(CustomMaterial.BLEND, Laya.RenderState.BLEND_ENABLE_ALL);
        this._shaderValues.setInt(CustomMaterial.BLEND_SRC, Laya.RenderState.BLENDPARAM_SRC_ALPHA);
        this._shaderValues.setInt(CustomMaterial.BLEND_DST, Laya.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA);
        this._shaderValues.setInt(CustomMaterial.DEPTH_TEST, Laya.RenderState.DEPTHTEST_LESS);
    }
    //漫反射贴图的存取函数
    get diffuseTexture() {
        return this._shaderValues.getTexture(CustomMaterial.DIFFUSETEXTURE);
    }
    set diffuseTexture(value) {
        this._shaderValues.setTexture(CustomMaterial.DIFFUSETEXTURE, value);
    }
    //设置marginalColor（边缘光照颜色）
    set marginalColor(value) {
        this._shaderValues.setVector(CustomMaterial.MARGINALCOLOR, value);
    }

}
//ES6可以定义静态属性，这些属性是CustomMaterial的属性，不属于CustomMaterial实例的属性。ES7提案将支持在class中使用static定义静态属性


